import Mock from 'mockjs'

import register from './register'
import firstPage from './firstPage'
import history from './history'
import apply from './apply'
import search from './search'

// 修复在使用 MockJS 情况下，设置 withCredentials = true，且未被拦截的跨域请求丢失 Cookies 的问题
// https://github.com/nuysoft/Mock/issues/300
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() {
  if (this.custom.xhr) {
    this.custom.xhr.withCredentials = this.withCredentials || false
  }
  this.proxy_send(...arguments)
}

// Mock.setup({
//   timeout: '10'
// })

// 总体情况

Mock.mock(/\/apis\/v1\/register/, 'post', register.save)
Mock.mock(/\/apis\/v1\/register/, 'get', register.get)

Mock.mock(/\/apis\/v1\/search/, 'get', search.index)


Mock.mock(/\/dajian\/h5\/firstPage/, 'post', firstPage.submit)
Mock.mock(/\/dajian\/h5\/history/, 'post', history.submit)
Mock.mock(/\/dajian\/h5\/cargoType/, 'post', apply.cargoType)
Mock.mock(/\/dajian\/h5\/carType/, 'post', apply.carType)
Mock.mock(/\/dajian\/h5\/cargoInfo/, 'post', apply.cargoInfo)
Mock.mock(/\/dajian\/h5\/carInfo/, 'post', apply.carInfo)
Mock.mock(/\/dajian\/h5\/cehicleCargoInfo/, 'post', apply.cehicleCargoInfo)
Mock.mock(/\/dajian\/h5\/passInfo/, 'post', apply.passInfo)
Mock.mock(/\/dajian\/h5\/handlerInfo/, 'post', apply.handlerInfo)
Mock.mock(/\/dajian\/h5\/otherInfo/, 'post', apply.otherInfo)

Mock.mock(/\/dajian\/h5\/search/, 'get', search.index)


export default Mock
